<template>
  <div>
    <div class="update" v-if="loading">
      <div>
        <span>订单编号</span>
        <input type="text" disabled v-model="order.order_id" />
      </div>
      <div>
        <span>实际支付</span>
        <input type="text" v-model="order.pay.pay_actual" />
      </div>
      <div>
        <span>订单状态</span>
        <input type="text" v-model="order.status" />
      </div>
      <div>
        <span>赠送积分</span>
        <input type="text" v-model="order.pay.pay_integral" />
      </div>
      <div>
        <span>订单备注</span>
        <input type="text" v-model="note" />
      </div>
      <button @click="submit">提交</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      order: {},
      note:null
    };
  },
  methods: {
    async fenchData(_id) {
      const { data: res } = await this.$http.order.findById({ _id });
      this.loading = true;
      this.order = res.data[0];
      console.log(this.order);
    },
   async submit(){
    let obj={
      _id:this.order.order_id,
      pay_actual:this.order.pay.pay_actual,
      pay_integral:this.order.pay.pay_integral,
      status:this.order.status,
      note:this.note
    }
      const {data:res}=await this.$http.order.UpdateData(obj)
      console.log(res.meta);
      // this.$router.push('/home/')
    }
  },
  created() {
    const { query } = this.$route;
    this.fenchData(query._id);
  },
};
</script>

<style lang='scss' scoped>
.update {
  padding: 20px;
  box-sizing: border-box;
  div {
    margin-bottom: 50px;
    span {
      margin-right: 20px;
    }
    input {
      outline: none;
      border: 1px solid skyblue;
      border-radius: 4px;
      width: 250px;
      height: 30px;
    }
  }
}
</style>